#include <stdio.h>
#include <string.h>

#define Max(a,b) ((a)>(b)?(a):(b))
int minimumRecolors(char* blocks, int k) {
    int bcount=0,bmax=0;
    int size=strlen(blocks);
    for( int i=0; i<size; i++ ){
        if( blocks[i]=='B' )
            bcount++;
        if( i < k-1 )
            continue;
        bmax=Max(bmax,bcount);
        if( blocks[ i-k+1 ] == 'B' )
            bcount--;
    }
    return k-bmax;
}

int main(){
    char *s="WBWBBBW";
    printf("%d\n",minimumRecolors(s,2));
    return 0;
}
